package net.dreamlu.car.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.dreamlu.car.mapper.CarInfoMenuDao;
import net.dreamlu.car.model.CarInfoMenu;
import net.dreamlu.car.service.CarInfoMenuService;
import net.dreamlu.common.result.Tree;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


@Service("carInfoMenuService")
public class CarInfoMenuServiceImpl extends ServiceImpl<CarInfoMenuDao, CarInfoMenu> implements CarInfoMenuService {


	@Override
	public List<Tree> selectTree() {
		List<CarInfoMenu> list = list();
		List<Tree> trees = new ArrayList<>();
		if (list != null) {
			for (CarInfoMenu organization : list) {
				Tree tree = new Tree();
				tree.setId(organization.getMenuId().intValue());
				tree.setText(organization.getName());
				tree.setIconCls(organization.getIcon());
				tree.setPid(organization.getParentId().intValue());
				trees.add(tree);
			}
		}
		return trees;
	}
}
